package br.com.comanda.webservice.model;

// Generated 08/05/2012 22:04:45 by Hibernate Tools 3.4.0.CR1

import static javax.persistence.GenerationType.IDENTITY;

import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;

import com.sun.xml.internal.bind.CycleRecoverable;

@XmlRootElement
@Entity
@Table(name = "account", catalog = "comanda")
public class Account implements java.io.Serializable, CycleRecoverable {

	private static final long serialVersionUID = 4355219734406157802L;

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	private Integer id;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "user_id", nullable = false)
	private User user;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "board_id", nullable = false)
	private Board board;

	@Column(name = "waiter", nullable = false, length = 50)
	private String waiter;

	@Column(name = "client", nullable = false, length = 50)
	private String client;

	@Column(name = "close", nullable = false)
	private boolean close;

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "date_close", length = 19)
	private Date dateClose;

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "account")
	private List<Item> items;

	// private Set<CountItens> countItenses = new HashSet<CountItens>(0);

	public Account() {
	}

	public Account(User user, Board board, String waiter, String client,
			boolean close) {
		this.user = user;
		this.board = board;
		this.waiter = waiter;
		this.client = client;
		this.close = close;
	}

	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public User getUser() {
		return this.user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public Board getBoard() {
		return this.board;
	}

	public void setBoard(Board board) {
		this.board = board;
	}

	public String getWaiter() {
		return this.waiter;
	}

	public void setWaiter(String waiter) {
		this.waiter = waiter;
	}

	public String getClient() {
		return this.client;
	}

	public void setClient(String client) {
		this.client = client;
	}

	public boolean isClose() {
		return this.close;
	}

	public void setClose(boolean close) {
		this.close = close;
	}

	public Date getDateClose() {
		return this.dateClose;
	}

	public void setDateClose(Date dateClose) {
		this.dateClose = dateClose;
	}

	public List<Item> getItems() {
		return this.items;
	}

	public void setItems(List<Item> items) {
		this.items = items;
	}

	public List<Item> getItens() {
		return this.items;
	}

	public Object onCycleDetected(Context context) {
		Account obj = new Account();
		obj.setId(this.id);
		return obj;
	}

}
